package com.xjrsoft.module.customerTwo.aiplm.t_aiplm_lease_work_order.service.impl;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.xjrsoft.core.tool.utils.StringUtil;
import com.xjrsoft.module.customerTwo.aiplm.t_aiplm_lease_work_order.entity.TAiplmLeaseWorkOrder;
import com.xjrsoft.module.customerTwo.aiplm.t_aiplm_lease_work_order.dto.TAiplmLeaseWorkOrderListDto;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.xjrsoft.common.page.ConventPage;
import com.xjrsoft.common.page.PageOutput;
import java.util.List;
import com.xjrsoft.module.customerTwo.aiplm.t_aiplm_lease_work_order.mapper.TAiplmLeaseWorkOrderMapper;
import com.xjrsoft.module.customerTwo.aiplm.t_aiplm_lease_work_order.service.ITAiplmLeaseWorkOrderService;
import com.xjrsoft.core.mp.base.BaseService;
import com.xjrsoft.core.tool.utils.Func;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.core.metadata.IPage;

/**
 *  服务实现类
 *
 * @author dongxinhang
 * @since 2024-07-03
 */
@Service
@AllArgsConstructor
public class TAiplmLeaseWorkOrderServiceImpl extends BaseService<TAiplmLeaseWorkOrderMapper, TAiplmLeaseWorkOrder> implements ITAiplmLeaseWorkOrderService {


	@Override
	public IPage<TAiplmLeaseWorkOrder> getPageList(TAiplmLeaseWorkOrderListDto pageListDto) {
		Wrapper<TAiplmLeaseWorkOrder> wrapper = Wrappers.<TAiplmLeaseWorkOrder>query().lambda()
				.like(!StringUtil.isEmpty(pageListDto.getF_OrderNum()), TAiplmLeaseWorkOrder::getFOrdernum, pageListDto.getF_OrderNum())
				.eq(!StringUtil.isEmpty(pageListDto.getF_Account()), TAiplmLeaseWorkOrder::getFAccount, pageListDto.getF_Account())
				.like(!StringUtil.isEmpty(pageListDto.getF_RealName()), TAiplmLeaseWorkOrder::getFRealname, pageListDto.getF_RealName())
				.eq(!StringUtil.isEmpty(pageListDto.getF_Type()), TAiplmLeaseWorkOrder::getFType, pageListDto.getF_Type());
		return this.page(ConventPage.getPage(pageListDto), wrapper);
	}

	@Override
	public boolean addTAiplmLeaseWorkOrder(TAiplmLeaseWorkOrder tAiplmLeaseWorkOrder) {
		boolean isSuccess = this.save(tAiplmLeaseWorkOrder);
		return isSuccess;
	}

	@Override
	public boolean updateTAiplmLeaseWorkOrder(String id, TAiplmLeaseWorkOrder tAiplmLeaseWorkOrder) {
		tAiplmLeaseWorkOrder.setFId(id);
		return this.updateById(tAiplmLeaseWorkOrder);
	}

	public boolean delete(String ids) {
		List<String> idList = Func.toStrList(ids);
		if (this.removeByIds(idList)) {
			return true;
		}
		return false;
	}

}